﻿using System;
using System.Data;
using System.Collections.Generic;
using SERP.DAO;
namespace SERP.Controllers{
public class SalaryDataControllerBase : Controller{
	public SalaryDataControllerBase()
		: base()
	{
	}
	private static SalaryDataDAO _Service; 
	public static SalaryDataDAO Service{
		get{
			if(_Service==null)
				_Service = new SalaryDataDAO();
			return _Service;
		}
		set{
			_Service = value;
		}
	}
    //Copy data from data row in grid to object
    public SalaryDataEntity MapDataRowToObject(DataRow row){
		SalaryDataEntity o = new SalaryDataEntity();
		 if(!row.IsNull("Salary"))
			o.Salary=ConvertNumber(row["Salary"]);
		 if(!row.IsNull("YearOfSalary"))
			o.YearOfSalary=ConvertInt(row["YearOfSalary"]);
		 if(!row.IsNull("MonthOfSalary"))
			o.MonthOfSalary=ConvertInt(row["MonthOfSalary"]);
		 if(!row.IsNull("UserId"))
			o.UserId=ConvertInt(row["UserId"]);
		 if(!row.IsNull("PersonId"))
			o.PersonId=(Int32)(row["PersonId"]);
		 if(!row.IsNull("SalaryFieldId"))
			o.SalaryFieldId=(Int32)(row["SalaryFieldId"]);
		 if(!row.IsNull("SalaryDataId"))
		    o.SalaryDataId=(Int32)(row["SalaryDataId"]);
		 return o;
    }
	//Copy data from object to data row in grid    
    public void MapObjectToDataRow(SalaryDataEntity o,DataRow row){
		row["Salary"]=o.Salary;
		row["YearOfSalary"]=o.YearOfSalary;
		row["MonthOfSalary"]=o.MonthOfSalary;
		row["UserId"]=o.UserId;
		row["PersonId"]=o.PersonId;
		row["SalaryFieldId"]=o.SalaryFieldId;
		row["SalaryDataId"]=o.SalaryDataId;
    }
}
}
